﻿using Simple.ISysService;
using Simple.Tools;
using SimpleSaas.Entity;
using SimpleSaas.Entity.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.SysService
/// <summary>
/// 版 本 钢易智企2.0 V 2.0.0 钢易智企2.0
/// Copyright (c) 2023 杭州钢易科技有限公司
/// 创建人：曾东明
/// 日 期：2024
/// 描 述：
/// </summary>
{
	public class SystemInitializeService : ISystemInitializeService
	{
		[Autowired]
		protected ISqlSugarClient dbClient { get; set; }

		/// <summary>
		/// 将实体类通过sugar code fist 创建数据库的表!
		/// </summary>
		/// <returns></returns>
		public async Task DatabaseCreateTablesAsync()
		{
			#region 第一次
			//dbClient.CodeFirst.InitTables(typeof(SysTenantEntity));
			//dbClient.CodeFirst.InitTables(typeof(SysAppEntity));
			//dbClient.CodeFirst.InitTables(typeof(SysAppTenantRelationEntity));
			//dbClient.CodeFirst.InitTables(typeof(SysDatabaseEntity));
			//dbClient.CodeFirst.InitTables(typeof(SysUserEntity));
			#endregion

			#region 第二次
			dbClient.CodeFirst.InitTables(typeof(SysMenuEntity));
			dbClient.CodeFirst.InitTables(typeof(SysTenantMenuRelationEntity));
			dbClient.CodeFirst.InitTables(typeof(SysRoleEntity));
			dbClient.CodeFirst.InitTables(typeof(SysRoleMenuRelationEntity));
			dbClient.CodeFirst.InitTables(typeof(SysUserRoleRelationEntity));
			dbClient.CodeFirst.InitTables(typeof(SysUserMenuRelationEntity));
			dbClient.CodeFirst.InitTables(typeof(SysUserDeptRelationEntity));
			dbClient.CodeFirst.InitTables(typeof(SysDepartmentEntity));
			#endregion
		}
	}
}
